package com.excesys.exsecs.linkage.controller;

import cn.hutool.core.util.ArrayUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.excesys.exsecs.common.core.util.R;
import com.excesys.exsecs.common.excel.annotation.ResponseExcel;
import com.excesys.exsecs.common.log.annotation.SysLog;
import com.excesys.exsecs.linkage.entity.SceneLinkage;
import com.excesys.exsecs.linkage.entity.SceneLinkageLog;
import com.excesys.exsecs.linkage.service.OperateLogsService;
import com.excesys.exsecs.linkage.service.SceneLinkageLogService;
import com.excesys.exsecs.linkage.service.SceneLinkageService;
import com.excesys.exsecs.linkage.vo.SceneLinkageVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springdoc.api.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 场景联动
 *
 * @author zhangtailong
 * @date 2024-05-20 14:09:13
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/sceneLinkageLog")
@Tag(description = "sceneLinkageLog", name = "场景联动管理日志")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class SceneLinkageLogController {

    private final SceneLinkageLogService sceneLinkageLogService;
    /**
     * 分页查询
     *
     * @param page         分页对象
     * @param sceneLinkageLog 场景联动日志
     * @return
     */
    @Operation(summary = "分页查询", description = "分页查询")
    @GetMapping("/page")
    public R getSceneLinkagePage(@ParameterObject Page page, @ParameterObject SceneLinkageLog sceneLinkageLog) {
        LambdaQueryWrapper<SceneLinkageLog> wrapper = new LambdaQueryWrapper<>();
		wrapper.like(StringUtils.isNotBlank(sceneLinkageLog.getLinkageId()),
						SceneLinkageLog::getLinkageId, sceneLinkageLog.getLinkageId())
				.orderByDesc(SceneLinkageLog::getCreateTime);

        return R.ok(sceneLinkageLogService.page(page, wrapper));
    }

}